package org.example.循环;

import java.util.Arrays;
import java.util.List;

/**
 * @author mumucgq
 * @create 2020-12-22 15:49
 */
public class ForTest {
    public static void main(String[] args) {
        List<String> userNames = Arrays.asList("Hollis", "hollis", "HollisChuang", "H");

        System.out.println("使用for循环遍历List");
        for (int i = 0; i < userNames.size(); i++) {
            System.out.println(userNames.get(i));
        }

        System.out.println("使用foreach遍历List");
        for (String userName : userNames) {
            System.out.println(userName);
        }
    }

}
